<form action="<? echo $info['url']; ?>" method="post" enctype="multipart/form-data">
    <table width="100%">
        <tr><td>
    <strong>Название:</strong><br />
    <input name="title" type="text" value="<? echo $info['title']; ?>" class="long" /><br />
    <strong>Производитель:</strong><br />
    <select name="fid">
        <?
            if ($info['fid']==0){
                echo '<option value="0">--Не выбрано--</option>';
            }
            $q=mysql_query('select * from firms order by title');
            while ($f=  mysql_fetch_assoc($q)){
                $sel='';
                if ($f['id']==$info['fid'])
                    $sel = 'selected="selected"';
                echo '<option value="'.$f['id'].'" '.$sel.'>'.$f['title'].'</option>';
            }
        ?>
    </select><br/>
    
    <br/>
    <table width="100%">
        <tr>
            <td>
    <strong>Состав:</strong><br />
    <ul id="SostavList">
        <?
            $q=mysql_query('select * from cat_sostav where idcat='.$info['id'].' order by id');
            while ($f=  mysql_fetch_assoc($q)){
                $poks=  mysql_query('select * from sostav where id='.$f['idsost']);
                while ($d=  mysql_fetch_assoc($poks)){
                    echo '<li><input class="SostavItem ui-autocomplete-input" value="'.$d['title'].'" /><a href="#" class="deleteSostav">D</a></li>  ';
                }
            }
        ?>
    </ul>
    <input id="AddSostavItem" type="button" value="Добавить ингредиент"/>
<script type="text/javascript">
  var Item;
  var $d = jQuery.noConflict();

  function AppendSostavItem(add){
        if (add)
            $d('ul#SostavList').append('<li><input id="SostavItem0" class="SostavItem ui-autocomplete-input" name="SostavItem0" /><a href="#" class="deleteSostav">D</a></li>');
        $d('ul#SostavList li').each(function(key, value){
            var ob = $d('input.ui-autocomplete-input',this).attr({'name':'SostavItem'+key, 'id':'SostavItem'+key});
            var obd = $d('a.deleteSostav',this).bind("click", function(){$d(this).parent().remove(); return false;});
            $d(ob).autocomplete({source: "/autocomplete/catalog/sostav", minLength:3});
        });
  }
  $d(document).ready(function() {
    AppendSostavItem(false);
    $d('#AddSostavItem').bind("click", function(){
        AppendSostavItem(true);
    });
    $d('.deleteSostav').bind('click',function(){
        AppendSostavItem(false);
    });
  });
  </script>
                
            </td>
            <td>
    <strong>Показания к применению:</strong><br />
    <ul id="PokazaniesList">
        <?
            $q=mysql_query('select * from cat_pokaz where idcat='.$info['id'].' order by id');
            while ($f=  mysql_fetch_assoc($q)){
                $poks=  mysql_query('select * from pokaz where id='.$f['idpokaz']);
                while ($d=  mysql_fetch_assoc($poks)){
                    echo '<li><input class="PokazanieItem ui-autocomplete-input" value="'.$d['title'].'" /><a href="#" class="deletePokazanie">D</a></li>  ';
                }
            }
        ?>
    </ul>
    <input id="AddPokazanieItem" type="button" value="Добавить показание"/>
<script type="text/javascript">
  var Item;
  var $d = jQuery.noConflict();

  function AppendPokazanieItem(add){
        if (add)
            $d('ul#PokazaniesList').append('<li><input id="PokazanieItem0" class="PokazanieItem ui-autocomplete-input" name="PokazanieItem0" /><a href="#" class="deletePokazanie">D</a></li>');
        $d('ul#PokazaniesList li').each(function(key, value){
            var ob = $d('input.ui-autocomplete-input',this).attr({'name':'PokazanieItem'+key, 'id':'PokazanieItem'+key});
            var obd = $d('a.deletePokazanie',this).bind("click", function(){$d(this).parent().remove(); return false;});
            $d(ob).autocomplete({source: "/autocomplete/catalog/pokaz", minLength:3});
        });
  }
  $d(document).ready(function() {
    AppendPokazanieItem(false);
    $d('#AddPokazanieItem').bind("click", function(){
        AppendPokazanieItem(true);
    });
    $d('.deletePokazanie').bind("click", function(){
        AppendPokazanieItem(false);
    });
  });
  </script>
            </td>
        </tr>
        </table>
    <br />
            </td>
            <td width="220px">
    <strong>Заболевание:</strong><br />
    <select name="zid" style="width:100%;">
        <?
            if ($info['zid']==0){
                echo '<option value="0">--Не выбрано--</option>';
            }
            $q=mysql_query('select * from zab order by title');
            $count=mysql_fetch_assoc(mysql_query('select count(id) as c from zab'));
            $i=0;
            $count= ceil($count['c']/2);
            $checks='<table ><tr><td style="vertical-align:top;">';
            $selected_count=0;
            $selected_collect='';
            while ($f=  mysql_fetch_assoc($q)){
                $sel='';
                if ($f['id']==$info['zid'])
                    $sel = 'selected="selected"';
                echo '<option value="'.$f['id'].'" '.$sel.'>'.$f['title'].'</option>';
                if (!empty($f['title'])){
                    $zab_set=  mysql_fetch_assoc(mysql_query('select id from cat_zab where idcat='.$info['id'].' and idzab='.$f['id']));
                    $c='';
                    if (isset($zab_set['id'])){
                        $c='checked="checked"';
                        $selected_collect.='<input type="hidden" name="zab'.$selected_count.'" value="'.$f['id'].'" />';
                        $selected_count++;
                    }
                    $checks.='<input type="checkbox" name="z'.$i.'" selid="'.$f['id'].'" '.$c.' />'.$f['title'].'<br/>';
                    
                    if ($i==$count)
                        $checks.='</td><td style="vertical-align:top;">';
                    $i++;
                }
                
            }
            $checks.='</td></tr></table>';
        ?>
    </select>
        <div id="zab_collect">
            <?=$selected_collect?>
        </div>
        <span id="zab_count">Выбрано:<?=$selected_count?></span>&nbsp;<a href="#" id="open_form_zab">Изменить</a>
    <br/>
        <strong>Форма выпуска:</strong><br />
        <input type="text" name="forma" class="med" style="width:100%;" value="<?=$info['forma']?>" /><br/>
        <strong>В упаковке:</strong><br />
        <input type="text" name="doza" class="med" style="width:100%;" value="<?=$info['doza']?>" /><br/>
<strong>Изображение</strong><br />
            <div style="height:170px; position:relative; float:left; padding:0px;margin-top:0px; margin-right: 0px; width:110px; text-align: center; border:1px solid #cccccc;">
                <script type="text/javascript">
                  function ready(file){
                      jQuery("#image").html("<img src='/images/catalog/<?=$info['id']?>---235.jpg' />");
                  }
                </script>
                <?
                    if (file_exists(LocalDir.'/images/catalog/'.$info['id'].'---235.jpg'))
                        $img='<img src="/images/catalog/'.$info['id'].'---235.jpg" width="100" />';
                    else
                        $img='<img src="/images/no-logo.jpg" width="110" />';
                ?>
                <span id="image" ><?=$img?></span>
                <div style="position:absolute; bottom: 5px; right: 5px;">
                    <span id="loader" ></span></div>
                <script type="text/javascript">
                    var flashvars = {
                            send_to: "/7ert54/process_files.php?catalog=<?=$info['id']?>",
                            endFunction: "ready",
                            file_desc:"*.jpg",
                            file_ext:"*.jpg"
                    };
                    var params = {
                            allowscriptaccess: "always",
                            allowFullScreen: "false",
                            wmode:'transparent',
                            name:"uploader"
                    };
                    var attributes = {
                            id: "uploader",
                            name:"uploader"
                    };
                    swfobject.embedSWF("/swf/upl.swf", "loader", "49px", "49px", "9.0.0", false, flashvars, params, attributes);
                    
                </script>
                
            </div> 
            </td>
        </tr>
    </table>
        <strong>Способ применения:</strong><br />
        <textarea name="sposob" class="med" style="height:50px;width:100%;"><? echo $info['sposob']; ?></textarea><br/>
        <strong>Побочные эффекты:</strong><br />
        <textarea name="pobochka" class="med" style="height:50px;width:100%;"><? echo $info['pobochka']; ?></textarea><br/>

    <?$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->Height = '500';
$oFCKeditor->BasePath = '/7ert54/fckeditor/';
$oFCKeditor->Value = stripslashes($info['description']);
$oFCKeditor->Create() ; 
?>


<input type="submit" value="Сохранить">
</form>
        <div class="many_check" style="display:none;"><?=$checks?></div>
        <script type="text/javascript">
            jQuery(document).ready(function(){
                
                jQuery('.many_check').dialog({autoOpen:false, title:'Заболевания для препарата', width: '650px',
                    buttons:{ 
                        "Отмена":function(){
                            jQuery(this).dialog("close");
                        },
                        "Выбрать": function() { 
                            i=0;
                            jQuery('#zab_collect').html('');
                            jQuery(".many_check input:checkbox[checked]").each(function(){
                                jQuery('#zab_collect').append('<input type="hidden" name="zab'+i+'" value="'+jQuery(this).attr('selid')+'" />');
                                i++;
                            });
                            jQuery('#zab_count').html('Выбрано:'+i);
                            jQuery(this).dialog("close"); 
                        }
                    }
                });
                jQuery('#open_form_zab').bind('click', function(){
                    jQuery('.many_check').dialog('open'); return false;
                });
            });
        </script>
